package com.effectiveui.away3d.primitives{
	import away3d.containers.ObjectContainer3D;
	import away3d.primitives.Sphere;
	
	import nl.fxc.away3d.material.MaterialUtil;

	public class Cube extends FlexObject3D{
		private var _Cube:away3d.primitives.Cube = new away3d.primitives.Cube();
		private var _segmentsW:Number;
		private var _segmentsH:Number;
		private var _radius:Number;
		
		public function Cube():void{
			this.object3D = this._Cube;
		}
		
		override protected function createChildren():void{
			super.createChildren();
		}
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			var oParent:ObjectContainer3D = this._Cube.parent;
			if(oParent != null){
				oParent.removeChild(this._Cube);
				if(this.needUpdate && MaterialUtil.isValid(this.material)){
					this._Cube = new away3d.primitives.Cube({material:this.material, radius:this.radius, segmentsW:this.segmentsW, segmentsH:this.segmentsH});
					this.needUpdate = false;
				}
				
				this._Cube.x = this.x;
				this._Cube.y = this.y;
				this._Cube.z = this.z; 
				this._Cube.rotationX = this.rotationX;
				this._Cube.rotationY = this.rotationY;
				this._Cube.rotationZ = this.rotationZ;
				this.object3D = this._Cube;
				oParent.addChild(this._Cube);
			}
		}
		public function get segmentsW():Number{
			return this._segmentsW;
		}
		public function set segmentsW(value:Number):void{
			this._segmentsW = value;
			this.needUpdate = true;
		}
		
		public function get segmentsH():Number{
			return this._segmentsH;
		}
		
		public function set segmentsH(value:Number):void{
			this._segmentsH = value;
			this.needUpdate = true;
		}
	}
}